﻿using System;
using System.Data;
using System.Globalization;
using Pantry.Business;
using Pantry.Entity;
namespace Pantry.Web.Users
{
    public partial class ViewListTypeOfBusiness : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (Request.QueryString["TypeName"] != null || Request.QueryString["Code"] != null)
            {
                CollectionPager.PageSize = 5;
                CollectionPager.BindToControl = RepeaterBusiness;
                CollectionPager.DataSource = new TypeOfBusinessBus().ReturnSearchValue(Request.QueryString["TypeName"], Request.QueryString["Code"]);
               
                if(CollectionPager.TotalRecords != 0)
                {
                    RepeaterBusiness.DataSource = CollectionPager.DataSourcePaged;
                    RepeaterBusiness.DataBind();
                }
                else
                {
                    var dt = new TypeOfBusinessBus().ListTypeOfBusinessToDataSet().Tables[0];
                    CollectionPager.PageSize = 5;
                    CollectionPager.BindToControl = RepeaterBusiness;
                    CollectionPager.DataSource = dt.DefaultView;
                    RepeaterBusiness.DataSource = CollectionPager.DataSourcePaged;
                    RepeaterBusiness.DataBind(); 
                }
            }

            else
            {
                var dt = new TypeOfBusinessBus().ListTypeOfBusinessToDataSet().Tables[0];
                CollectionPager.PageSize = 5;
                CollectionPager.BindToControl = RepeaterBusiness;
                CollectionPager.DataSource = dt.DefaultView;
                RepeaterBusiness.DataSource = CollectionPager.DataSourcePaged;
                RepeaterBusiness.DataBind();
            }
        }
        protected void Search_Click(object sender, EventArgs e)
        {
            Response.Redirect("ViewListTypeOfBusiness.aspx?TypeName=" + textboxBusiness.Text.Trim() + "&Code=" + TextboxSIC.Text.Trim() + "");

        }
        protected void None_Click(object sender, EventArgs e)
        {
            Response.Redirect("ViewListTypeOfBusiness.aspx");
        }
        protected void Clear_Click(object sender, EventArgs e)
        {
            textboxBusiness.Text = null;
            TextboxSIC.Text = null;
        }
    }
}
